Description:
IDFC detects situations where precision may be lost as a result of integer division. It can happen when an integer value is divided by another integer and the result is either assigned to a floating-point variable, or the result is used in a floating-point expression. It may not be clear that the conversion to a floating-point type is done after the division.
Incorrect:
procedude calcBounds(size:integer);
var border:double;
begin
border := size div 20;
// if size was 18, d now unexpectably equals 0.0
...
end;
Correct:
procedude calcBounds(size:integer);
var border:double;
begin
border := size / 20;
...
end;